<?php
import ( 'admin.Action.AdministratorAction' );
class AdminAction extends AdministratorAction {
	public function _initialize() {
		parent::_initialize ();
		$_GET ['flag'] = isset ( $_GET ['flag'] ) ? $_GET ['flag'] : 1;
	}
	function index() {
		$askModel = new AskModel ();
		$contextModel = D ( 'ask_context' );
		$do = $_GET ['do'];
		if ($do == 'del') {
			$data = array ();
			$id = $_GET ['id'];
			$data ['ask_id'] = intval ( $id );
			$data ['ask_flag'] = - 1;
			if ($contextModel->save ( $data )) {
				// 清缓存
				$cacheName = getCacheName ( "ask@context/id:" . $id . ";" );
				S ( $cacheName, NULL );
				$cacheName = getCacheName ( 'ask@action:show/id:' . $id . ';' );
				S ( $cacheName, NULL );
				$this->success ( '删除成功' );
			} else {
				$this->error ( '删除失败' );
			}
		} elseif ($do == 'close') {
			$data = array ();
			$id = $_GET ['id'];
			$data ['ask_id'] = intval ( $id );
			$data ['ask_flag'] = 0;
			if ($contextModel->save ( $data )) {
				// 清缓存
				$cacheName = getCacheName ( "ask@context/id:" . $id . ";" );
				S ( $cacheName, NULL );
				$cacheName = getCacheName ( 'ask@action:show/id:' . $id . ';' );
				S ( $cacheName, NULL );
				$this->success ( '关闭成功' );
			} else {
				$this->error ( '关闭失败' );
			}
		} elseif ($do == 'hot') {
			$data = array ();
			$id = $_GET ['id'];
			$data ['ask_id'] = intval ( $id );
			$data ['ask_sort'] = 1;
			if ($contextModel->save ( $data )) {
				// 清缓存
				$cacheName = getCacheName ( "ask@context/id:" . $id . ";" );
				S ( $cacheName, NULL );
				$cacheName = getCacheName ( 'ask@action:show/id:' . $id . ';' );
				S ( $cacheName, NULL );
				$this->success ( '推荐成功' );
			} else {
				$this->error ( '推荐失败' );
			}
		} elseif ($do == 'delHot') {
			$data = array ();
			$id = $_GET ['id'];
			$data ['ask_id'] = intval ( $id );
			$data ['ask_sort'] = 0;
			if ($contextModel->save ( $data )) {
				// 清缓存
				$cacheName = getCacheName ( "ask@context/id:" . $id . ";" );
				S ( $cacheName, NULL );
				$cacheName = getCacheName ( 'ask@action:show/id:' . $id . ';' );
				S ( $cacheName, NULL );
				$this->success ( '取消推荐成功' );
			} else {
				$this->error ( '取消推荐失败' );
			}
		}
		$this->list = $askModel->listAsk ( '', $_GET ['flag'] );
		$this->display ();
	}
	function tag() {
		$this->display ();
	}
	function category() {
		$this->display ();
	}
	function file() {
		$this->display ();
	}
}
?>